#-*- coding:utf8 -*-
#!/usr/bin/python
'''
author: lixinpan
createTime: 2021-07-23 11:50
update: lixinpan
updateTime: 2021-07-23 11:50
description: list的加法和乘法
'''

def list_expand_base():
    L0 = [1,2,3]
    L1 = L0+L0
    L2 = L0*3
    print(L1)
    print(L2)

def list_expand_mult():
    # 每次都新建空间
    L0 = ['_']
    L1 = [L0*3 for i in range(3)]
    print(L1)
    L1[0][1] = 'M'
    print(L1)

def list_expand_mult1():
    L0 = ['_']
    L1 = L0*3
    L2 = [L1  for i in range(3)]
    print(L2)
    L2[0][1] = 'M'
    print(L2)

def list_expand_mult2():
    L0 = ['_']
    L1 = [L0*3]
    L2 = L1*3
    print(L2)
    L2[0][1] = 'M'
    print(L2)
    print(id(L2))

if __name__ == "__main__":
    # list_expand_base()
    # list_expand_mult()
    list_expand_mult1()
    list_expand_mult2()